export function timestampToHHMMSS(value) {
	if (typeof(value) == 'undefined') {
		return ''
	} else {
		let date = new Date(parseInt(value))
		let y = date.getFullYear()
		let MM = date.getMonth() + 1
		MM = MM < 10 ? ('0' + MM) : MM
		let d = date.getDate()
		d = d < 10 ? ('0' + d) : d
		let h = date.getHours()
		h = h < 10 ? ('0' + h) : h
		let m = date.getMinutes()
		m = m < 10 ? ('0' + m) : m
		let s = date.getSeconds()
		s = s < 10 ? ('0' + s) : s
		return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
	}
}


export function handler(timestamp) {
	let date = new Date(parseInt(timestamp) * 1000);
	let y = date.getFullYear();
	let m = date.getMonth() + 1;
	let d = date.getDate();
	let h = date.getHours();
	let min = date.getMinutes();
	let sec = date.getSeconds();

	if (m < 10) {
		m = "0" + m;
	}
	if (d < 10) {
		d = "0" + d;
	}
	if (h < 10) {
		h = "0" + h;
	}
	if (min < 10) {
		min = "0" + min;
	}
	if (sec < 10) {
		sec = "0" + sec;
	}

	return `${y}-${m}-${d} ${h}:${min}:${sec}`;
}